using System;
using System.Collections.Generic;
using Microsoft.AspNetCore.Mvc.RazorPages;
using Microsoft.AspNetCore.Mvc.Rendering;
using Microsoft.AspNetCore.Mvc;
using Models;
using IDAL;
using Microsoft.AspNetCore.Http;

namespace ITAM.Pages.Assets
{
    public class ImportDeviceModel : PageModel
    {
        private IExcelService excelService;

        [BindProperty]
        public List<DeviceRecord> Devices { get; set; }

        [BindProperty]
        public IFormFile ExcelFile { get; set; }

        public ImportDeviceModel(IExcelService excelService)
        {
            this.excelService = excelService;
        }

        public IActionResult OnPostUploadDevice()
        {
            if (ExcelFile == null)
            {

                Console.WriteLine("没有获取到文档");
            }
            else
            {
                Console.WriteLine("获取到文档");
                Console.WriteLine(ExcelFile.FileName);
            }
            return Page();
        }

        public IActionResult OnPostImportDevice()
        {
            return RedirectToPage("./Device");
        }

    }
}